# !/usr/bin/python3
# -*- coding:utf-8 -*-
"""
@author: JHC000abc@gmail.com
@file: model_users.py
@time: 2024/11/5 20:46 
@desc: 

"""
from sqlalchemy.sql import func
from sqlalchemy import Column, INT, VARCHAR, DateTime, Enum
from db.base_model import Base


class UserInfo(Base):
    """
    用户表
    """

    __tablename__ = 'user_info'
    id = Column(INT, primary_key=True, autoincrement=True, nullable=False, index=True, unique=True)
    user_name = Column(VARCHAR(255), unique=True, nullable=False)
    password = Column(VARCHAR(255), unique=False, nullable=False)
    grade = Column(Enum("0", "1", "2"), unique=False, nullable=False, default="0",
                  comment="用户类型:0:普通 1:管理员 2:开发账号")
    status = Column(Enum("0", "1", "2"), nullable=False, default="0", comment="0:正常 1:禁止 2:废弃")
    superior = Column(INT, nullable=True, unique=False, comment="上级用户id(注册此账号的用户id)")
    create_time = Column(DateTime, nullable=False, server_default=func.now(), comment="创建时间")
    update_time = Column(DateTime, nullable=False, server_default=func.now(), onupdate=func.current_timestamp(),
                         comment="更新时间")
    __table_args__ = {
        'mysql_charset': 'utf8mb4'  # 设置字符集为utf8mb4
    }


STATUS_NORMAL = "0"
STATUS_DORBIDDEN = "2"
USER_NORMAL = "0"
USER_MANAGER = "1"
USER_ROOT = "2"
